import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace SensitiveWordApi {
  /** 系统敏感词信息 */
  export interface SensitiveWord {
    id: number; // id
    name?: string; // 敏感词
    tags?: string; // 标签
    status?: number; // 状态
    description: string; // 描述
  }
}

/** 查询系统敏感词分页 */
export function getSensitiveWordPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<SensitiveWordApi.SensitiveWord>>(
    '/system/sensitive-word/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询系统敏感词详情 */
export function getSensitiveWord(id: number) {
  return requestClient.get<SensitiveWordApi.SensitiveWord>(
    `/system/sensitive-word/get?id=${id}`,
  );
}

/** 新增系统敏感词 */
export function createSensitiveWord(data: SensitiveWordApi.SensitiveWord) {
  return requestClient.post('/system/sensitive-word/create', data);
}

/** 修改系统敏感词 */
export function updateSensitiveWord(data: SensitiveWordApi.SensitiveWord) {
  return requestClient.put('/system/sensitive-word/update', data);
}

/** 删除系统敏感词 */
export function deleteSensitiveWord(id: number) {
  return requestClient.delete(`/system/sensitive-word/delete?id=${id}`);
}

/** 批量删除系统敏感词 */
export function deleteSensitiveWordList(ids: number[]) {
  return requestClient.delete(
    `/system/sensitive-word/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出系统敏感词 */
export function exportSensitiveWord(params: any) {
  return requestClient.download('/system/sensitive-word/export-excel', {
    params,
  });
}
/** 获取敏感词标签 */
export function getTags() {
  return requestClient.get('/system/sensitive-word/get-tags');
}
/** 更新敏感词状态 */
export function updateSensitiveWordStatus(data: any) {
  return requestClient.put('/system/sensitive-word/update-status', data);
}
